package com.msy.rabbit.demo.listener;

import com.msy.rabbit.demo.dao.OrderRepository;
import com.msy.rabbit.demo.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

@Component
public class RabbitListener {
    @Autowired
    private OrderRepository repository;

    @org.springframework.amqp.rabbit.annotation.RabbitListener(queues = "queue.dlx")
    public void timeoutOrder(Message message){
        Order order = (Order) message.getPayload();
        order.setState("3");//超时取消
        repository.save(order);
        System.out.println(message.getPayload());



    }
}
